package com.bawei.image

/**
 * Author: Jason Zhang
 * Date: 2025/1/10
 * Desc: 封装图片参数类
 */
class ImgOptions private constructor(
    val placeImage: Int,
    val errorImage: Int,
    val isGif: Boolean,
    val imgSize: IntArray,
    val skipMemory: Boolean,
    val skipDiskCache: Boolean,
    val isCircle: Boolean,
    val roundRadius: Int
) {

    /**
     * 使用建造者模式，封装参数
     */
    companion object Builder {

        private var placeImage: Int = 0
        private var errorImage: Int = 0
        private var isGif: Boolean = false
        private var imgSize: IntArray = intArrayOf()
        private var skipMemory: Boolean = false
        private var skipDiskCache: Boolean = false
        private var isCircle: Boolean = false
        private var roundRadius: Int = 0

        fun placeImage(placeImage: Int): Builder{
            this.placeImage = placeImage
            return this
        }

        fun errorImage(errorImage: Int): Builder{
            this.placeImage = errorImage
            return this
        }

        fun isGif(isGif: Boolean): Builder{
            this.isGif = isGif
            return this
        }

        fun imgSize(size: IntArray): Builder{
            this.imgSize = size
            return this
        }

        fun skipMemory(skipMemory: Boolean): Builder{
            this.skipMemory = skipMemory
            return  this
        }

        fun skipDiskMemory(skipDiskMemory: Boolean): Builder{
            this.skipDiskCache = skipDiskMemory
            return this
        }

        fun isCircle(isCircle: Boolean): Builder{
            this.isCircle = isCircle
            return this
        }

        fun roundRadius(radius: Int): Builder{
            this.roundRadius = radius
            return this
        }

        fun build(): ImgOptions {
            return ImgOptions(placeImage, errorImage, isGif, imgSize, skipMemory, skipDiskCache, isCircle, roundRadius)
        }
    }


}